/**************************
 * Source Submissions Panel
 */
AIR2.Source.Submissions = function() {
    Logger("AIR2.Source.BASEURL", AIR2.Source.BASEURL);
    return new AIR2.UI.Panel({
        colspan: 2,
        title: 'Submissions',
        showTotal: true,
        showAllLink: AIR2.Source.SUBMSRCH,
        iconCls: 'air2-source-submissions-icon',
        storeData: AIR2.Source.SUBMDATA,
        url: AIR2.Source.BASEURL + '/submissions',
        itemSelector: '.air2-source-submissions',
        tpl: new Ext.XTemplate(
                '<div class="air2-source-submissions">' +
                '<table>' +
                  '<tpl for="."><tr>' +
                    '<td>' +
                      '{[AIR2.Format.inquiryTitle(values.Inquiry, true)]}<br/>' +
                      '{[this.getContent(values)]} {[AIR2.Format.submissionMore(values)]}' +
                    '</td>' +
                    '<td class="subm-info">{[AIR2.Format.date(values.srs_date)]}</td>' +
                  '</tr></tpl>' +
                '</table>' +
                '</div>'  ,
                {
                    compiled: true,
                    disableFormats: true,
                    getName: function(values) {
                        if (!values.Source)
                            return "unknown source";
                        if (values.Source.src_first_name && values.Source.src_last_name)
                            return values.Source.src_last_name + ", " + values.Source.src_first_name;
                        return values.Source.src_username;
                    },
                    getTitle: function(values) {
                        //var noTags = Ext.util.Format.stripTags(values.Question.ques_value);
                        var noTags = Ext.util.Format.stripTags(values.Inquiry.inq_title);
                        return Ext.util.Format.ellipsis(noTags, 110, true);
                    },
                    getContent: function(values) {
                        var noTags = Ext.util.Format.stripTags(values.SrcResponse[0].sr_orig_value);
                        return Ext.util.Format.ellipsis(noTags, 180, true);
                    }
                }
        )        
    });
}
